/**
 * Created by wilson on 3/14/15.
 */
(function () {
    angular.module('app')
        .factory('markerService', markerService);

    markerService.$inject = ['$window'];
    function markerService($window) {
        var MS = {
            createCarMarker: createCarMarker,
            moveMarker: moveMarker
        };

        function moveMarker(marker, x, y, zoom) {
            var point = marker.getPosition();


        }

        function createCarMarker(map, x, y, zoom) {
            var point = new BMap.Point(x, y);
            map.centerAndZoom(point, zoom);
            var marker = new BMap.Marker(point);  // 创建标注
            map.addOverlay(marker);               // 将标注添加到地图中
            marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
            var opts = {
                width: 200,    // 信息窗口宽度
                height: 25,     // 信息窗口高度
                title: '车主位置',
                enableAutoPan: true //自动平移
            };
            var infoWindow = new BMap.InfoWindow('', opts);  // 创建信息窗口对象
            marker.addEventListener("click", function () {
                map.openInfoWindow(infoWindow, point); //开启信息窗口
            });
        }


        return MS;
    }
})();